<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/* 
	核销二维码
*/
class Check_qrcode extends Base_Controller{
	
	private $addtime = 30;

	public function __construct(){
		parent::__construct();
	}
	
	public function index(){
		$this->ci_smarty->assign([
			'refresh_time' => $this->addtime - 5
		]);
		$this->ci_smarty->display('check_qrcode.htm');
	}
	
	public function generate(){
		$this->load->helper('common');
		$this->load->library('ci_qrcode');
		$validtime = time() + $this->addtime;
		$data = $this->_url['home'].'/order/check?token=';
		// $data = 'http://192.168.30.29:8081/food/order/check?token=';
		$char = json_encode([
			'validtime' => $validtime,
			'sign' => mmd5($validtime)
		]);
		$data .= urlencode(secret_char($char));
		header("Content-Type: image/png");
		$this->ci_qrcode->generate([
			'data' => $data,
			'size' => 400
		]);
	}
	
}